<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/common/taglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="${ctx}/static/lib/layui/css/layui.css">
</head>
<style type="text/css">
	.main_div{
		margin : 15px;
	}
</style>

<body>

<form class="layui-form layui-form-pane" action="" id="form_add">
   <div class="layui-form-item">
    <label class="layui-form-label">父类ID</label>
    <div class="layui-input-block">
    <!--lay-verify="required" 这个语句是自带的正则表达式，包含的意思是 该文本框不能为空(必填项) -->
      <input type="text" name="parentId" lay-verify="required" autocomplete="off" placeholder="请输入父类ID" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">类别名称</label>
    <div class="layui-input-block">
    <!--lay-verify="required" 这个语句是自带的正则表达式，包含的意思是 该文本框不能为空(必填项) -->
      <input type="text" name="name" lay-verify="required" autocomplete="off" placeholder="请输入类别名称" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">排序编号</label>
    <div class="layui-input-block">
      <input type="text" name="sortOther" lay-verify="required" placeholder="请输入编号" autocomplete="off" class="layui-input">
    </div>
  </div>
 

  
  <!--单选按钮开始  -->
  <div class="layui-form-item" pane="">
    <label class="layui-form-label">类别状态</label>
    <div class="layui-input-block">
      <input type="radio" name="status" value="1" title="tree" checked="">
      <input type="radio" name="status" value="0" title="flase">
    </div>
  </div>
  <!--单选按钮结束  -->
  
  <!--提交按钮开始 -->
  <div class="layui-form-item">
    <input class="layui-btn" onclick="submitForm()" lay-filter="demo2" value="添加" />
  </div>
</form>
  <!--提交按钮结束 -->
          
<script src="${ctx}/static/back/js/jquery.min.js?v=2.1.4"></script>
<script src="${ctx}/static/common/mylayer.js"></script>
<script src="${ctx}/static/common/util.js"></script>
<script src="${ctx}/static/lib/layui/layui.js"></script>
<script src="${ctx}/static/lib/kindeditor/kindeditor.js"></script>
<script src="${ctx}/static/lib/kindeditor/lang/zh_CN.js"></script>


<script>
layui.use(['form', 'upload' ], function(){
  var form = layui.form;
 	upload = layui.upload;
 	
 	form.render('select');//刷新select选择框渲染
 	
 	//ajax方式提交form表单
	function submitForm() {
		$.ajax({
			url:"${ctx}/category/add.action",
			//data 提交 ,serialize 序列化
			data:$('#form_add').serialize(),
			type:"post",
			dataType:"json",
			success:function(resp) {
				if(resp.code == util.SUCCESS) {
					mylayer.confirm("添加成功，是否跳转到列表界面？","${ctx}/category/getProductPage.action");
				}
				else{
					mylayer.errorMsg(resp.msg);
				}
			}
			
		});
 	}
});
</script>

</body>
</html>